package com.cloud.feign.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.feign.apiservice.PersonService;
import com.cloud.feign.entity.Person;

@RestController
public class InvokerController {

	@Autowired
	PersonService personService;

	@PostMapping(value = "/post", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	public Person get(@RequestBody Person person) {
		return personService.findPerson(person);
	}

	@GetMapping("/errorGet")
	public String errorGet() {
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return "this is e error request!";
	}
}
